package com.ruoyi.pg.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.pg.domain.Attachment;
import com.ruoyi.pg.mapper.AttachmentMapper;
import com.ruoyi.pg.service.IAttachmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 附件管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-07
 */
@Service
public class AttachmentServiceImpl implements IAttachmentService 
{
    @Resource
    private AttachmentMapper attachmentMapper;

    /**
     * 查询附件管理
     * 
     * @param attachId 附件管理主键
     * @return 附件管理
     */
    @Override
    public Attachment selectAttachmentByAttachId(Long attachId)
    {
        return attachmentMapper.selectAttachmentByAttachId(attachId);
    }

    /**
     * 查询附件管理列表
     * 
     * @param attachment 附件管理
     * @return 附件管理
     */
    @Override
    public List<Attachment> selectAttachmentList(Attachment attachment)
    {
        List<Attachment> list = attachmentMapper.selectAttachmentList(attachment);
        return list;
    }

    /**
     * 新增附件管理
     * 
     * @param attachment 附件管理
     * @return 结果
     */
    @Override
    public int insertAttachment(Attachment attachment)
    {
        attachment.setCreateTime(DateUtils.getNowDate());
        return attachmentMapper.insertAttachment(attachment);
    }

    /**
     * 修改附件管理
     * 
     * @param attachment 附件管理
     * @return 结果
     */
    @Override
    public int updateAttachment(Attachment attachment)
    {
        return attachmentMapper.updateAttachment(attachment);
    }

    /**
     * 批量删除附件管理
     * 
     * @param attachIds 需要删除的附件管理主键
     * @return 结果
     */
    @Override
    public int deleteAttachmentByAttachIds(Long[] attachIds)
    {
        return attachmentMapper.deleteAttachmentByAttachIds(attachIds);
    }

    /**
     * 删除附件管理信息
     * 
     * @param attachId 附件管理主键
     * @return 结果
     */
    @Override
    public int deleteAttachmentByAttachId(Long attachId)
    {
        return attachmentMapper.deleteAttachmentByAttachId(attachId);
    }

    /**
     * 根据附件ID列表查询附件信息
     * @param ids
     * @return
     */
    @Override
    public List<Attachment> selectAttachmentByAttachIds(List<Long> ids) {
        return attachmentMapper.selectAttachmentListByIds(ids);
    }

    @Override
    public List<Attachment> selectAttachmentByIndicatorIdAndFileName(Long indicatorId, String fileName){
        return this.attachmentMapper.selectAttachmentByIndicatorIdAndFileName(indicatorId,fileName);
    }

    @Override
    public Attachment selectAttachmentByTeacherId(Long teacherId) {
        return this.attachmentMapper.selectAttachmentByTeacherId(teacherId);
    }

    @Override
    public void deleteAttachmentByTeacherIds(Long[] teacherIds) {
        this.attachmentMapper.deleteAttachmentByTeacherIds(teacherIds);
    }


}
